package com.atguigu.gulimall.test.service.impl;

import com.atguigu.gulimall.test.entity.Teacher;
import com.atguigu.gulimall.test.service.TService;

import java.util.ArrayList;
import java.util.List;

public class TeacherServiceImpl implements TService<Teacher> {

    private List<Teacher> list = new ArrayList<>();

    @Override
    public void add(Teacher teacher) {
        this.list.add(teacher);
    }

    @Override
    public Teacher get(Teacher teacher) {
        for (Teacher teacher1 : list) {
            if(teacher1.getId().toString().equals(teacher.getId().toString())){
                return teacher1;
            }
        }
        return null;
    }

    @Override
    public void update(Teacher teacher) {
        for (Teacher teacher1 : list) {
            if(teacher1.getId().toString().equals(teacher.getId().toString())){
                teacher1.setName(teacher.getName());
            }
        }
    }
}
